const nodemailer = require('nodemailer');

const sendEmail = async (options) => {
  //1)create a transport
  const transport = nodemailer.createTransport({
    service: 'QQ',
    auth: {
      user: process.env.EMAIL_USERNAME,
      pass: process.env.EMAIL_USERPASSWORD,
    },
  });
  //2)define the email options
  const mailOptions = {
    from:'GJE <gje0714@qq.com>',
    subject:options.subject,
    to:options.email,
    text:options.message

  }
  //3)actually send the email
  await transport.sendMail(mailOptions)
};
module.exports = sendEmail